﻿using Halcon二次开发.View.结果分析工具;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Halcon二次开发.Controller.结果分析工具
{
    public class AnalyseControl
    {
        //输入参数
        public double[] IntputArrays;
        //输出结果
        public bool[] OutputResults;
        /// <summary>
        /// 窗体结果分析对象
        /// </summary>
        private AnalyseResultForms analyseResultForms;
        public AnalyseControl(AnalyseResultForms analyseResultForms)
        {
            this.analyseResultForms = analyseResultForms;
        }
        public void Run()
        {
            if (IntputArrays != null && IntputArrays.Length > 0)
            {
                OutputResults = new bool[IntputArrays.Length];
                int Min = (int)analyseResultForms.numericUpDown1.Value;
                int Max = (int)analyseResultForms.numericUpDown2.Value;
                if (Min < Max)
                {
                    for (int i = 0; i < IntputArrays.Length; i++)
                    {
                        if (IntputArrays[i] > Min && IntputArrays[i]<Max)
                        {
                            OutputResults[i] = true;
                        }
                        else
                        {
                            OutputResults[i] = false;
                        }
                    } 
                }
                else throw new Exception("参数上下限错误");
            }
            else throw new Exception("分析工具没有得到数据");
        }
    }
}
